﻿@model XPressify.Models.MediaUploadModel


<div>
    <div>
        Description:<br />
        @Html.TextAreaFor(m => m.FileDescription, 2, 39, new { style = "resize: none;", id = "desc"})
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            var auth = "@(Request.Cookies[FormsAuthentication.FormsCookieName] == null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value)";
            var aId = "@(Model.Id)";
            var uId = "@(Model.UserId)";

            $('#fileInput').uploadify({
                uploader: '../../Content/flash/uploadify.swf',
                script: '/@Model.ControllerName/@Model.ActionName',
                folder: '/Media',
                cancelImg: '../../Content/images/cancel.png',
                auto: false,
                multi: false,
                removeCompleted: false,
                queueID: 'custom-queue',
                scriptData: { albumId: aId, userId: uId, token: auth, description: $('#desc').val() },
                fileDesc: 'Any document type',
                fileExt: '@Model.FileExtension',
                sizeLimit: 5000000,
                scriptAccess: 'always', //testing locally. comment before deploy
                buttonText: 'Browse...'
            });

            $("#btnSave").button().click(function (event) {
                event.preventDefault();
                var finput = $('#fileInput');
                var auth1 = "@(Request.Cookies[FormsAuthentication.FormsCookieName] == null ? string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value)";
                var aId1 = "@(Model.Id)";
                var uId1 = "@(Model.UserId)";
                finput.uploadifySettings('scriptData', { albumId: aId1, userId: uId1, token: auth1, description: $('#desc').val() });
                finput.uploadifyUpload();
            });

        });
        </script>
        <div>
            <div id="status-message"></div>
            <div id="custom-queue" class="uploadifyQueue"></div>
        </div>
        
        <div>
            <input id="fileInput" name="fileInput" type="file" style="vertical-align:right" />
        </div>
</div>